package CHART;

import java.awt.Font;
import java.util.List;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;

public class PartmentScoreChart {
	
	public static void pie(List<Object> list) {
		 
		
			
		
		DefaultPieDataset dpd = new DefaultPieDataset();
		
		if(list!=null) //循环数据列表，生成表格行
		{
			for(int i=0;i<list.size();i++)
    		{
   				Object[] obj;
   				obj=(Object[])list.get(i);
   				
   				
    		
		
	    dpd.setValue((Comparable)obj[1],(Number) obj[3]);  
    		}
	      
		
	}
		JFreeChart chart = ChartFactory.createPieChart3D("院得分饼状图", dpd, true, true, false);
		Font font = new Font("SimSun", 10, 20);
		TextTitle txtTitle = null;
		txtTitle = chart.getTitle();
		txtTitle.setFont(font);
		PiePlot pieplot = (PiePlot) chart.getPlot();
		pieplot.setLabelFont(font);
		chart.getLegend().setItemFont(font);
		ChartFrame pieFrame = new ChartFrame("院得分饼状图", chart);
		pieFrame.pack();
		pieFrame.setFont(font);
		pieFrame.setVisible(true);
	}
		public static void category(List<Object> list)
		{
			
			DefaultCategoryDataset dataSet = new DefaultCategoryDataset();  
		    // 向数据集合中添加数据  
			if(list!=null) //循环数据列表，生成表格行
    		{
    			for(int i=0;i<list.size();i++)
        		{
       				Object[] obj;
       				obj=(Object[])list.get(i);
       				
       				
        		
    		
		    dataSet.addValue((Number) obj[3], "院得分", (Comparable) obj[1]);  
		      
			
		}
	}
		    StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); //创建主题样式  
		    standardChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 20)); //设置标题字体  
		    standardChartTheme.setRegularFont(new Font("宋体", Font.PLAIN, 15)); //设置图例的字体  
		    standardChartTheme.setLargeFont(new Font("宋体", Font.PLAIN, 8)); //设置轴向的字体  
		    ChartFactory.setChartTheme(standardChartTheme);//设置主题样式  
		    // 通过ChartFactory创建JFreeChart  
		    JFreeChart chart2 = ChartFactory.createBarChart3D(  
		            "院得分统计", //图表标题  
		            "学院名称", //横轴标题  
		            "得分",//纵轴标题  
		           dataSet,
		            PlotOrientation.VERTICAL, //图表方向  
		            true,//是否显示图例标识  
		            false,//是否显示teletypes  
		            false);//是否支持超链接  
		    ChartFrame cf = new ChartFrame("院得分柱状图", chart2);  
		    cf.pack();  
		    cf.setVisible(true);  
		}

}
